# -*- coding: utf-8 -*-

import unittest
import os
import codecs
import json
from json_loader import JsonLoader
from model.gamestate import *


class JsonLoaderTest(unittest.TestCase):
    def setUp(self):
        with codecs.open(os.path.join('test_data', 'example.json'),
                         encoding='utf-8', mode='r') as f:
            self.json_string = f.read()

    def test_json_translate(self):
        self.game_state = JsonLoader().json_translate(json.loads(
            self.json_string))
        self.assertTrue(isinstance(self.game_state.players, Players))
        self.assertTrue(isinstance(self.game_state.hat, Hat))
        self.assertTrue(isinstance(self.game_state.settings, Settings))


if __name__ == "__main__":
    unittest.main()
